import { FC } from 'react';
import { Routes, Route, useLocation } from 'react-router-dom';
import Home from './pages/Home';
import Community from './pages/Community';
import Resources from './pages/Resources';
import OpenSource from './pages/OpenSource';
import Editor from './pages/Editor';
import Navbar from './components/navbar';
import './App.less';

// 不需要导航栏的路由页面
const withoutNavbarRoutes = [
  '/editor',
];

const App: FC = () => {
  const { pathname } = useLocation();

  return (
    <div>
      {/* 导航栏 */}
      { withoutNavbarRoutes.includes(pathname) || <Navbar /> }
      {/* 路由 */}
      <div className='page-container'>
        <Routes>
          <Route path='/' element={ <Home /> }>
            <Route index></Route>
            <Route path='follow' />
            <Route path='latest' />
            <Route path='hot' />
          </Route>
          <Route path='/community' element={ <Community /> } />
          <Route path='/resources' element={ <Resources /> } />
          <Route path='/opensource' element={ <OpenSource /> } />
          <Route path='/editor' element={ <Editor /> } />
        </Routes>
      </div>
    </div>
  );
};

export default App;
